
import request from '../utils/request'

// 会员登录 process.env.WXAPPID 为当前小程序 appId 下同
const userLogin = data => request.post(`/s-wechat/open/mnp/${process.env.WXAPPID}/user-login`, data)

// 拿取微信绑定的手机号
const wechatUserPhone = data => request.post(`/s-wechat/open/mnp/${process.env.WXAPPID}/new-user-phone?code=` + data.code)

// 拿取微信个人信息[废弃不用]
const wechatUserInfo = data => request.post(`/s-wechat/open/mnp/${process.env.WXAPPID}/user-info`, data)

// 会员个人信息（来自自身服务数据库信息）
const userInfo = () => request.get('/s-mall/api/member/info')

// 绑定手机号到会员
const bindPhone = data => request.post('/s-mall/api/member/bind-phone?phone=' + data.phone)

/**
 * @description: 用户订阅消息
POST /s-mall/api/subscribe/subscribe
接口ID：40883813
接口地址：https://www.apifox.cn/web/project/1207715/apis/api-40883813
 * @param {*} {appId，orderId，scene}
 * @returns
 */
const Subscribe = data => request.post('/s-mall/api/subscribe/subscribe', data)

/**
 * @description: 落地页通过短链场景值获取真实路径参数
GET /s-wechat/api/landing/{scene}
接口ID：33710680
接口地址：https://www.apifox.cn/web/project/1207715/apis/api-33710680
 * @param {*} scene
 * @returns
 */
const getLandingScene = scene => request.get(`/s-wechat/api/landing/${scene}`)

/**
 * @description: 访问记录
POST /s-mall/api/access-log/loginaccess
接口ID：48090613
接口地址：https://www.apifox.cn/web/project/1207715/apis/api-48090613
 * @param {*} data
 * @returns
 */
const accessLogAdd = data => request.post(`/s-mall/api/access-log/loginaccess`, data)


/**
 * @description: 检查取消/注销会员是否满足条件
GET /s-mall/api/member/check-member-cancel-condition
接口ID：52959201
接口地址：https://www.apifox.cn/web/project/1207715/apis/api-52959201
 * @param {*}
 * @returns
 */
const checkCondition = () => request.get('/s-mall/api/member/check-member-cancel-condition')

/**
 * @description: 使用签名方式代第三方领奖
POST /s-mall/api/reward-log/create
接口ID：55925696
接口地址：https://www.apifox.cn/web/project/1207715/apis/api-55925696
 * @param {*} data
 * @returns
 */
const rewardLogCreate = data => request.post(`/s-mall/api/reward-log/create`, data)


/**
 * @description: 查询第三方领奖记录
GET /s-mall/api/reward-log/query
接口ID：55926266
接口地址：https://www.apifox.cn/web/project/1207715/apis/api-55926266
 * @param {*}
 * @returns  params
 */
const rewardLogQuery = params => request.get('/s-mall/api/reward-log/query', params)

/**
 * @description: 使用活动页面id换取页面url
GET /s-content/api/web-page/url/{id}
接口ID：56229459
接口地址：https://www.apifox.cn/web/project/1207715/apis/api-56229459
 * @param {*} id
 * @returns
 */
const getWebPageUrl = id => request.get(`/s-content/api/web-page/url/${id}`)

export const UploadTrackInfo = data => request.post(`/s-mall/api/event-tracking/upload`, data)

export {
    userLogin,
    wechatUserPhone,
    wechatUserInfo,
    userInfo,
    bindPhone,
    getLandingScene,
    Subscribe,
    accessLogAdd,
    checkCondition,
    rewardLogCreate,
    rewardLogQuery,
    getWebPageUrl
}
